#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);


    ui->comboBox->addItem("巨⽆霸");
    ui->comboBox->addItem("⻨辣鸡腿堡");
    ui->comboBox_2->addItem("薯条");
    ui->comboBox_2->addItem("⻨辣鸡翅");
    ui->comboBox_3->addItem("可乐");
    ui->comboBox_3->addItem("雪碧");

}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    QString orderInfo = "你下单的商品是:\n";
    // 处理主食类
    if (ui->groupBox->isChecked()) {
        QString food = ui->comboBox->currentText();
        int count = ui->spinBox->value();
        orderInfo += QString("%1  %2份\n").arg(food).arg(count);
    }
    // 处理小食类
    if (ui->groupBox_2->isChecked()) {
        QString snack = ui->comboBox_2->currentText();
        int count = ui->spinBox_2->value();
        orderInfo += QString("%1  %2份\n").arg(snack).arg(count);
    }
    // 处理可乐类
    if (ui->groupBox_3->isChecked()) {
        QString drink = ui->comboBox_3->currentText();
        int count = ui->spinBox_3->value();
        orderInfo += QString("%1  %2份\n").arg(drink).arg(count);
    }
    // 将下单信息显示到文本框中，假设用于显示的控件是QTextEdit，objectName为textEdit
    ui->label->setText(orderInfo);
}

